//index.js
Page({
  data: {
    temp: "断网了",
    avgtemp: "检查一下网络吧",
    type: "真的没网",
    city: "没网了",
    date: "No Internet Connection",
    wind: "试试Wifi？",
    future: '[]',
  },
  onLoad: function() {
    console.log('onload')
    var that = this
    var result = null;
    wx.request({
      url: 'http://apis.juhe.cn/simpleWeather/query?',
      data: {
        "city":"成都",
        "key":"2a7edc345ac0bca1edbf83e5f61c0140"
      },
      success(res){
        result = res.data.result;
        var test1 = JSON.stringify(result);
        console.log(test1)
        that.setData({
          city:res.data.result.city,
          temp: res.data.result.realtime.temperature,
          avgtemp: res.data.result.future[0].temperature,
          type: res.data.result.future[0].weather,
          wind: res.data.result.future[0].direct,
          date: res.data.result.future[0].date,
          future: res.data.result.future,
        })
      }
    })
  },
  onReady: function() {
    console.log('onReady')
  },
  onShow: function() {
    console.log('onShow')
  },
  onHide: function() {
    console.log('onHide')
  },
})